(WIP) Cleaned Flux2 Klein Implementation, with benchmarking done on v6 TPU#434
Draft
amepas wants to merge 4 commits into
Draft
(WIP) Cleaned Flux2 Klein Implementation, with benchmarking done on v6 TPU#434amepas wants to merge 4 commits into
amepas wants to merge 4 commits into
Conversation
entrpn
reviewed
Jun 30, 2026
|
|
||
| class GenerateFlux2KleinE2ETest(unittest.TestCase): | ||
|
|
||
| def test_end_to_end_parity_and_offloading(self): |
Collaborator
There was a problem hiding this comment.
this test is very likely to fail in the github runner with the hardcoded values. We usually don't run e2e tests on the github runner, you can mark it so it doesn't run in the runner.
entrpn
reviewed
Jun 30, 2026
| every single stage against the golden PyTorch reference. | ||
| """ | ||
| # Set highest precision for strict mathematical parity checks | ||
| jax.config.update("jax_default_matmul_precision", "highest") |
Collaborator
There was a problem hiding this comment.
what is the reason for using highest here?
entrpn
requested changes
Jun 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(WIP) - this will be updated with multi-chip latency and support for Flux2 Klein 9B!
Draft PR for the Flux2 Klein model. Includes a custom implementation of the Qwen3-4B model for getting text embeddings. VAE Decoder, RoPE positional embedder, flow-matching step schedule are all re-used. Light modifications to transformer/attention blocks are used.
Latency for batch-size 4 of 1024 by 1024 images (bfloat16):
57.67 ms(1.58% of total)3,181.20 ms(87.09% of total)795.30 ms413.77 ms(11.33% of total)PR includes code for verifying accuracy of implementation. Sharding model is implemented but not tested.
Image generation is only supported so far.